
<div class="templatemo-content-wrapper">
	<div class="templatemo-content">
		<ol class="breadcrumb">
			<li><a href="<?=site_url()?>/order/index">订单管理</a></li>
			<li class="active">订单列表</li>
		</ol>
		<div class="row margin-bottom-30">
			<div class="col-md-12">
				<ul class="nav nav-pills">
					<li class="active"><a href="<?=site_url()?>/order/index">返回订单列表</a></li>
				</ul>
			</div>
		</div>
		<div class="row">
			<div class="col-md-12">
				<div class="table-responsive">
					<h4 class="margin-bottom-15">添加订单</h4>
					<form role="form" id="templatemo-preferences-form"
						onsubmit="return false;">
						<div class="row">
							<div class="col-md-6 margin-bottom-15">
								<label for="firstName" class="control-label">饭店名称</label> <input
									type="text" class="form-control" id="name" value="">
							</div>
							<div class="col-md-6 margin-bottom-15">
								<label for="lastName" class="control-label">收货时间</label> <input
									type="text" class="form-control" id="date" value="<?php echo date('Y-m-d',strtotime ( "+1 day" )); ?>">
							</div>
							<div class="col-md-6 margin-bottom-15">
								<label for="firstName" class="control-label">备注</label> <input
									type="text" class="form-control" id="note" value="">
							</div>
						</div>
						<div class="row templatemo-form-buttons">
							<div class="col-md-12">
								<button type="submit" class="btn btn-primary" id="submit_btn">添加</button>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
<script>
	$(document).ready(function() {
		$("#name").autocomplete({
			minLength:1,
			source:function(request,response){
       			 $.ajax({
                    url:'<?php echo site_url('user/getUsers')?>',
                    type : "post",
                    dataType: "json",
                    data:{
                        name: request.term
                    },
                    success: function( data ) {
                        response($.map(data, function(item) {
    		            return {
    		                 label: item.shopname+'-'+item.id,
    		                 value: item.shopname+ '-' + item.id
    		             }
    		         }));
                    }
                });
			}
		});
		$("#submit_btn").click(function() {
			var name = $("#name").val();
			var note = $("#note").val();
			var date = $("#date").val();
			$.ajax({
				url : '<?php echo site_url('order/saveorder')?>',
				type : "post",
				async : true,
				data : {
					'name' : name,
					'note' : note,
					'date' : date,
				},
				dataType : "json",
				success : function(data) {
					if(data.code)
					{
						alert(data.msg);
						window.location.reload();
					}else{
						alert(data.msg);
					}
				}
			});
		});
		$('#date').datepicker({
			dateFormat: 'yy-mm-dd',
			monthNames: ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
			dayNamesMin: ['日','一','二','三','四','五','六']
		});
	}); 
</script>